//api文件夹用于存放对后台请求的代码
import service from ".";//导入
import qs from 'qs'

const adminApi = {
    top5Dept(){
        return service.get('/admin/top5Dept');
    },
    userOrder(){
        return service.get('/admin/userOrder');
    },
    login(admin) {
        return service.post("/admin/login",qs.stringify(admin));
    },
    captcha(){
        return service.get('/admin/captcha');
    },
    //获取已登录用户的信息
    getInfo(){
      return service.get('/admin/info')
    },
    insert(admin) {
        return service.post("/admin", admin);
    },
    delete(id) {
        return service.delete(`/admin/${id}`);
    },
    update(admin) {
        return service.put("/admin", admin);
    },
    //分页搜索
    selectByPage(condition, pageNum, pageSize) {
        condition.pageNum = pageNum;
        condition.pageSize = pageSize;
        return service.get("/admin/search", {
            params: condition
        });
    },
    //根据id查询
    selectById(id) {
        return service.get(`/admin/${id}`);
    },
    //修改密码
    changePwd(changePassword){
        return service.put("/admin/changePwd", qs.stringify(changePassword));
    },
    //重置密码
    backPwd(id){
        return service.put(`/admin/${id}`);
    }
};

export default adminApi;//导出